from typing import List


class Solution:
    def maximumLength(self, nums: List[int]) -> int:
        n = len(nums)
        if n <= 2: return 2
        length = 1
        prev = nums[0] & 1
        for i in range(1, n):
            if (nums[i] & 1) != prev:
                length += 1
                prev = prev ^ 1
        return length


if __name__ == '__main__':
    s = Solution()
    r = s.maximumLength([2, 39, 23])
    print(r)
